package com.ruoyi.tkType.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tkType.domain.QtTkType;
import com.ruoyi.tkType.service.IQtTkTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 题型Controller
 * 
 * @author ruoyi
 * @date 2021-11-19
 */
@RestController
@RequestMapping("/tkType/tkType")
public class QtTkTypeController extends BaseController
{
    @Autowired
    private IQtTkTypeService qtTkTypeService;

    /**
     * 查询题型列表
     */
    @PreAuthorize("@ss.hasPermi('tkType:tkType:list')")
    @GetMapping("/list")
    public TableDataInfo list(QtTkType qtTkType)
    {
        startPage();
        List<QtTkType> list = qtTkTypeService.selectQtTkTypeList(qtTkType);
        return getDataTable(list);
    }

    /**
     * 导出题型列表
     */
    @PreAuthorize("@ss.hasPermi('tkType:tkType:export')")
    @Log(title = "题型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QtTkType qtTkType)
    {
        List<QtTkType> list = qtTkTypeService.selectQtTkTypeList(qtTkType);
        ExcelUtil<QtTkType> util = new ExcelUtil<QtTkType>(QtTkType.class);
        return util.exportExcel(list, "题型数据");
    }

    /**
     * 获取题型详细信息
     */
    @PreAuthorize("@ss.hasPermi('tkType:tkType:query')")
    @GetMapping(value = "/{tkTypeId}")
    public AjaxResult getInfo(@PathVariable("tkTypeId") String tkTypeId)
    {
        return AjaxResult.success(qtTkTypeService.selectQtTkTypeByTkTypeId(tkTypeId));
    }

    /**
     * 新增题型
     */
    @PreAuthorize("@ss.hasPermi('tkType:tkType:add')")
    @Log(title = "题型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QtTkType qtTkType)
    {
        return toAjax(qtTkTypeService.insertQtTkType(qtTkType));
    }

    /**
     * 修改题型
     */
    @PreAuthorize("@ss.hasPermi('tkType:tkType:edit')")
    @Log(title = "题型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QtTkType qtTkType)
    {
        return toAjax(qtTkTypeService.updateQtTkType(qtTkType));
    }

    /**
     * 删除题型
     */
    @PreAuthorize("@ss.hasPermi('tkType:tkType:remove')")
    @Log(title = "题型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tkTypeIds}")
    public AjaxResult remove(@PathVariable String[] tkTypeIds)
    {
        return toAjax(qtTkTypeService.deleteQtTkTypeByTkTypeIds(tkTypeIds));
    }
}
